#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define dchar char
dchar one;
uchar qian,bai,shi,ge,cyc,time;
uint temp;
uchar code table[]={
0xC0,0xf9,0xA4,0xB0,
0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,
0xC6,0xA1,0x86,0x8E};
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P2_3 = P2^3;
void shownum(uchar qian,uchar bai,uchar shi,uchar ge,uchar cyc,uchar time);
void delay(uint z);
void main()
{
	qian=temp/1000;
	bai=temp%1000/100;
	shi=temp%100/10;
	ge=temp%10;
	while(1)
	{
		temp=1539;
		shownum(qian,bai,shi,ge,100,5)
		temp=5723;
		shownum(qian,bai,shi,ge,100,5)
	}
}
void shownum(uchar qian,uchar bai,uchar shi,uchar ge,uchar cyc,uchar time)
{
for(one=0;one<cyc;one++)
		{
			//qbsg
			P0=table[qian];
			P2_0=0;
			delay(time);
			P2_0=1;
			P0=table[bai];
			P2_1=0;
			delay(time);
			P2_1=1;
			P0=table[shi];
			P2_2=0;
			delay(time);
			P2_2=1;
			P0=table[ge];
			P2_3=0;
			delay(time);
			P2_3=1;
		}
}
void delay(uint z)
{
	uint x,y;
	for(x=z;x>0;x--)
		for(y=110;y>0;y--);	
}